package autotd.server;

import java.net.*;

import java.util.*;
import java.awt.Point;
import java.io.*;

import autotd.*;

public class BasicWatcher extends Thread implements NetworkProtocol {
	private BufferedReader myInput;

	public BasicWatcher() throws Exception {
		Socket connector = new Socket("localhost", DEFAULT_PORT_NUMBER);
		PrintStream output = new PrintStream(connector.getOutputStream());
		myInput = new BufferedReader(new InputStreamReader(connector.getInputStream()));
		output.println(WATCHER_REQUEST);
		output.flush();
	}

	public void run() {
		try {
			while (true) {
				String nextLine = myInput.readLine();
				if (nextLine == null) {
					break;
				}
				System.out.println(nextLine);
			}
		} catch(Exception e) {
			System.err.println("ERROR: " + e);
		}
	}
	
	public static void main(String[] args) throws Exception {
		(new BasicWatcher()).start();
	}
}





